package lyj.springcloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lyj.springcloud.entities.CommonResult;
import lyj.springcloud.myselfblockhandler.CustomBlockHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * sentinel 持久化规则
 */
@RestController
public class SentinelPersistenceController {

    @GetMapping("/rateLimit/byUrl/{id}")
    @SentinelResource(value = "retaLimit/byUrl"
                      ,blockHandler = "myselfHandle1"
                      ,blockHandlerClass = CustomBlockHandler.class)
    public CommonResult byUrl(@PathVariable("id") String id) {
        return new CommonResult("entinel 持久化规则 测试 id：" + id);
    }


//    @GetMapping("/rateLimit/customerBlockHandler")
//    @SentinelResource(value = "customerBlockHandler",
//            blockHandlerClass = CustomBlockHandler.class,
//            blockHandler = "myselfHandle2") // 指定调用的方法
//    public CommonResult customerBlockHandler(String id)
//    {
//        return new CommonResult("200","按客戶自定义限流处理 id : " + id);
//    }


}
